package org.zwy.gradetrack.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.zwy.gradetrack.entity.DirectEvaluation;
import org.zwy.gradetrack.vo.DirectEvaluationVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 直接评价 Mapper 接口
 */
@Mapper
public interface DirectEvaluationMapper extends BaseMapper<DirectEvaluation> {
    List<DirectEvaluation> selectByCourseAndIndicator(Integer courseId, Integer indicatorId);

    /**
     * 分页查询直接评价列表，包含课程名称、指标点名称和评价人名称
     *
     * @param page 分页参数
     * @param evaluation 查询条件
     * @return 评价列表
     */
    List<DirectEvaluationVO> pageDirectEvaluationsWithDetails(
            Page<DirectEvaluationVO> page,
            @Param("evaluation") DirectEvaluation evaluation
    );

    @Select("SELECT evaluation_score FROM direct_evaluation " +
            "WHERE indicator_id = #{indicatorId} " +
            "AND academic_year = #{evaluationYear} " +
            "ORDER BY evaluation_time DESC LIMIT 1")
    BigDecimal selectLatestEvaluationScore(Long indicatorId, Integer evaluationYear);
} 